package com.huilam.restactions.services.actions;

import javax.servlet.http.HttpServletRequest;

import com.huilam.restactions.common.RESTAction;
import com.huilam.restactions.common.HttpReqClient;
import com.huilam.restactions.interfaces.IRESTAction;

public class Echo implements IRESTAction {

	@Override
	public String doActions(RESTAction restActionConfig, HttpReqClient reqClient) {
		
		/*
		 * [restaction.property]
		 * 
		 * echo.path=/echo/{message}
		 * echo.classname=com.huilam.restactions.services.actions.Echo
		 * echo.req.methods=GET,PUT,POST,DELETE
		 *
		 */
		
		HttpServletRequest req = reqClient.getHttpRequest();
		
		String sEcho 			= reqClient.getRESTUrlParam("message");
		String sReqRemoteAddr 	= req.getRemoteAddr();
		String sReqMethod 		= reqClient.getRequestMethod();
		
		return "Echo: "+sEcho+" ("+sReqRemoteAddr+" - "+sReqMethod+")";
	}

}
